/**
 * Created by zhifu on 2015/3/16.
 */
var now = new Date();
function alterTime(){
    var opg = new Date("8/08/2008 20:00:00");
    now.setTime(now.getTime()+1000);

    day = (now-opg)/1000/60/60/24;
    dnum = Math.floor(day);
    hour = (now-opg)/1000/60/60 -24*dnum;
    hnum = Math.floor(hour);
    if(hnum.toString().length ==1){
        hnum = "0"+hnum;
    }
    minuts = (now-opg)/1000/60-60*24*dnum-60*hnum;
    mnum = Math.floor(minuts);
    if(mnum.toString().length ==1){
        mnum = "0"+mnum;
    }
    seconds = (now-opg)/1000-60*60*24*dnum-60*60*hnum-60*mnum;
    snum = Math.round(seconds);
    if(snum.toString().length ==1){
        snum = "0"+snum;
    }
    str = "距离北京奥运会已经过去 "+ dnum +" 天 "+hnum+" 时 "+mnum+"<span style='margin: 0 7px 0 7px'>分</span><font style='color: red'>"+snum +"</font>秒";
    document.getElementById("hello").innerHTML = str;
}
setInterval(alterTime,1000);
